package com.dlwx.firefighting.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.dlwx.firefighting.R;
import com.dlwx.firefighting.adapter.WithdrawHisAdapter;
import com.dlwx.firefighting.config.Constant;
import com.github.jdsjlzx.ItemDecoration.DividerDecoration;
import com.github.jdsjlzx.interfaces.OnItemClickListener;
import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WithdrawHisActivity extends BaseActivity {

    @BindView(R.id.title_left_one_btn)
    ImageView titleLeftOneBtn;
    @BindView(R.id.title_left_one_tv)
    TextView titleLeftOneTv;
    @BindView(R.id.title_left_two_btn)
    ImageView titleLeftTwoBtn;
    @BindView(R.id.title_left_two_tv)
    TextView titleLeftTwoTv;
    @BindView(R.id.tv_middle_title)
    TextView tvMiddleTitle;
    @BindView(R.id.title_right_one_btn)
    ImageView titleRightOneBtn;
    @BindView(R.id.title_right_two_btn)
    ImageView titleRightTwoBtn;
    @BindView(R.id.title_right_one_tv)
    TextView titleRightOneTv;
    @BindView(R.id.title_right_one_tv2)
    TextView titleRightOneTv2;
    @BindView(R.id.recyclerView)
    LRecyclerView recyclerView;
    WithdrawHisAdapter mAdapter;
    private int type;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_withdraw_his);
        ButterKnife.bind(this);
        initView();
    }

    private void initView() {
        switch (type){
            case Constant.WITH_DRAW:
                tvMiddleTitle.setText("提现记录");
                break;
            case Constant.RED_PACKAGE:
                tvMiddleTitle.setText("红包金额记录");
                break;
            case Constant.TRADE:
                tvMiddleTitle.setText("交易抵扣记录");
                break;
        }

        titleLeftOneBtn.setVisibility(View.VISIBLE);
         type=getIntent().getIntExtra("type",0);
        mAdapter=new WithdrawHisAdapter(this,type);
        List<String> mDatas=new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            mDatas.add("");
        }
        mAdapter.setDataList(mDatas);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        LRecyclerViewAdapter lRecyclerViewAdapter=new LRecyclerViewAdapter(mAdapter);
        recyclerView.setAdapter(lRecyclerViewAdapter);
        DividerDecoration divider = new DividerDecoration.Builder(this)
                .setHeight(R.dimen.divider_height_1)
//                .setPadding(R.dimen.divider_padding)
                .setColorResource(R.color.bg)
                .build();
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(divider);
        lRecyclerViewAdapter.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                switch (type){
                    case Constant.WITH_DRAW:
                        startActivity(new Intent(WithdrawHisActivity.this,WithdrawDetailActivity.class));
                        break;
                    case Constant.RED_PACKAGE:
                        startActivity(new Intent(WithdrawHisActivity.this,RedPackageDetailActivity.class));
                        break;
                    case Constant.TRADE:
                        startActivity(new Intent(WithdrawHisActivity.this,DikouDetailActivity.class));
                        break;
                }
            }
        });
    }

    @OnClick({R.id.title_left_one_btn, R.id.tv_middle_title})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.title_left_one_btn:
                this.finish();
                break;
            case R.id.tv_middle_title:
                break;
        }
    }
}
